{include file="$header"}
<div id="app" v-cloak>
    <el-curd 
        :field="field"
        :copy-multiple="false"
        :search-date="false"
        :search-keyword="false"
        :table-operation-width="250"
        @get-data="refresh($event)"
        preview>
    </el-curd>
</div>
<script>
    new Vue({
        el: '#app',
        data() {
            return {
                field: [
                    {
                        label: '基础设置',
                        field: [
                            {
                                label: '编号', 
                                prop: 'id',
                                table: false,
                            },
                            {
                                prop: 'cover', 
                                label: '封面', 
                                table: {is: 'image',width: '70px'},
                                form: {
                                    is: 'el-file-select',
                                    type: 'image',
                                    tips: '请<a href="https://www.iconfont.cn/collections/detail?spm=a313x.7781069.1998910419.d9df05512&cid=20107" target="_blank">点击此处</a>选择语言封面，48*32是最佳像素',
                                },
                            },
                            {
                                prop: 'title', 
                                label: '名称', 
                                table: {label: ''},
                                form: {
                                    placeholder: '例：日本',
                                    rules: [
                                        {required: true,message: '请输入语言名称'},
                                    ]
                                }
                            },
                            {
                                prop: 'name', 
                                label: '缩写', 
                                table: {sort: true},
                                form: {
                                    placeholder: '例：jp',
                                    update: false,
                                    rules: [
                                        {required: true,message: '请输入语言缩写'},
                                        {pattern:  /^[A-Za-z0-9_\-]+$/ig,message: '只能输入字母、数字、下划线_、破折号-'},
                                    ]
                                }
                            },
                            {
                                prop: 'default',
                                label: '默认',  
                                table: {prop: 'c_default'},
                                form: {
                                    is: 'el-switch',
                                    default: 0, 
                                },
                            },
                            {
                                prop: 'status',
                                label: '状态',  
                                table: {prop: 'c_status'},
                                form: {
                                    is: 'el-switch',
                                    default: 1, 
                                },
                            },
                        ]
                    },
                    {
                        label: '参数设置',
                        field: [
                            {
                                prop: 'parameter',
                                label: '参数',  
                                table: false,
                                form: {
                                    is: 'el-parameter',
                                    search: true,
                                    default: {:json_encode($defaultParameter)}, 
                                },
                            }
                        ]
                    },
                ]
            }
        },
        methods: {
            refresh(res) {
                let arr = [];
                res.data.forEach(function (item, index) {
                    if (item.status === 1) {
                        arr.push(item);
                    }
                });
                parent.parentVm.langAllow = JSON.parse(JSON.stringify(arr));
            }
        }
    })
</script>
{include file="$footer"}